//
//  Array+Duplicates.swift
//  MobileRTCSwiftSample
//
//  Created by zhangheng on 2019/9/19.
//  Copyright © 2019 Zoom Video Communications, Inc. All rights reserved.
//

import Foundation

extension Array where Element: Hashable {
    
    func removingDuplicates() -> [Element] {
        var addedDict = [Element: Bool]()
        return filter {
            addedDict.updateValue(true, forKey: $0) == nil
        }
    }
    
    //数组删除重复的
    mutating func removeDuplicates() {
        self = self.removingDuplicates()
    }
    
    //数组删除元素
    mutating func remove(objct:Element) {
        self = self.filter{$0 != objct}
    }
    
    //数组删除元素
    mutating func removeIndex(of:Element) {
        let index = (self as NSArray).index(of: of)
        self.remove(at: index)
    }
    
}
